<?php

	/**
	 * Verifies bootstrapper execution to ensure file
	 * necessities, and disabling direct access
	 */
	defined('ENGINE') or exit;
	
	/**
	 * Exception handler, this terminates the script execution 
	 * if an exception is fatal and buffer non fatal exceptions 
	 * so they can be displayed on the template
	 */
	function engine_exception_handler(Exception $e)
	{		
		if($e instanceof Engine_Basic_Exception)
		{
			engine_doc_error($e);
		}
		else if($e instanceof Engine_Exception)
		{
			die($e->getMessage());
		}
		
		if(Engine::globals('error_reporting'))
		{
			if(!(Engine::globals('errors') instanceof ArrayObject))
			{
				Engine::globals('errors', new ArrayObject);
			}

			Engine::globals('errors')->append($e->getMessage());
		}
	}

?>